package util;

public class TimeCounter
{
	private long time;
	private int clicks;
	private long avgTime;
	
	public TimeCounter()
	{
		this.time = 0;
		this.clicks = 0;
	}
	
	/**
	 * Get the average time in seconds
	 * @return
	 */
	public synchronized long getAvgTime()
	{
		if ( clicks == 0 )
			return 0;
		else
			return time / clicks / 1000;
	}
	
	/**
	 * Increase the total time with the specified time
	 * @param t
	 * @return
	 */
	public synchronized long increaseTime(long t)
	{
		return(this.time += t);
	}
	
	/**
	 * Increase the total number of clicks
	 * @return
	 */
	public synchronized int increaseClicks()
	{
		return(this.clicks++);
	}
	
	public long getTime()
	{
		return this.time;
	}
	
	public int getClicks()
	{
		return this.clicks;
	}
}
